using VixCOM;

namespace Weever.VmWare
{
    public class Host
    {
        private readonly IHost _host;

        internal Host(IHost host)
        {
            _host = host;
        }

        public VM OpenVM(string vmxFilePath)
        {
            IJob job = _host.OpenVM(vmxFilePath, null);
            IVM vm = (IVM)Library.Wait(job)[0];

            return new VM(vm);
        }

        public VM RegisterVM(string vmxFilePath)
        {
            IJob job = _host.RegisterVM(vmxFilePath, null);
            IVM vm = (IVM) Library.Wait(job)[0];

            return new VM(vm);
        }

        public void UnregisterVM(string vmxFilePath)
        {
            IJob job = _host.UnregisterVM(vmxFilePath, null);
            Library.Wait(job);
        }

        public void Disconnect()
        {
            _host.Disconnect();
        }
    }
}
